fix(runtime-shim): emit absolute proxy URLs using proxyBase#21
Merged
Conversation
The server-side url-rewriter emits absolute proxy URLs when proxyBase is set (commit 0b5ce10) so cross-origin-embedded pages resolve assets against the canonical proxy host. The client runtime shim never matched: it emitted root-relative /web/... paths that the browser resolves against the embedding/browsing host, leaking the wrong hostname for every runtime-built URL (fetch, XHR, element src/href, document.write, MutationObserver). The earlier anti-double-wrap guard made it worse by stripping proxyBase off already-absolute proxy URLs, demoting correct absolute URLs to relative. Mirror buildProxyUrl: a proxify() helper prepends proxyBase to every emitted proxy path. Already-absolute proxy URLs are left untouched (idempotent, no demotion); root-relative ones are upgraded to absolute when proxyBase is set. When proxyBase is unset, output stays root-relative (backward-compatible direct-proxy default). Tests updated to assert the canonical-absolute contract. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The server-side url-rewriter emits absolute proxy URLs when
proxyBaseis set (commit 0b5ce10) so cross-origin-embedded pages resolve assets against the canonical proxy host. The client runtime shim never matched — it emitted root-relative/web/...paths that the browser resolves against the embedding/browsing host, leaking the wrong hostname for every runtime-built URL (fetch, XHR, elementsrc/href,document.write, MutationObserver).The earlier anti-double-wrap guard made it worse: it stripped
proxyBaseoff already-absolute proxy URLs, demoting correct absolute URLs back to relative.Fix
Mirror the server's
buildProxyUrl: aproxify()helper prependsproxyBaseto every emitted proxy path.proxyBaseis set.proxyBaseis unset, output stays root-relative (backward-compatible direct-proxy default).Notes
Secondary to Keeping-History/infra#9 (which corrects the
PROXY_BASE_URLvalue). This change matters when a page is reached via a different host thanPROXY_BASE_URL(cross-origin embed, or the box DNS).Tests
Updated to assert the canonical-absolute contract. Full suite: 794 passing, typecheck clean, build OK.
🤖 Generated with Claude Code